<?php defined('SYSPATH') or die('No direct access allowed.');

	 class View_Jqgrid{
		
		private $template = 'jqgrid/template';
		private $scripts = array();
		private $grid_conf = NULL;
		private $grid_parameters = array();
		
		public function __construct($grid_conf, $grid_parameters = false, $scripts = false){
			$this->grid_conf = $grid_conf;
			$this->grid_parameters = ($grid_parameters)? $grid_parameters: $this->grid_parameters;
			$this->scripts = ($scripts)? $scripts: $this->scripts;
			Fire::log($this->scripts);
		}
		
		public function render($entity_name, $template = false){
			$view = ($template)? View::factory($template) : View::factory($this->template);
			$view->list_name = "list_".$entity_name;
			$view->pager_name = "gridpager_".$entity_name;
			$view->scripts = $this->scripts; //user defined scripts
			$view->grid_model = View::factory($this->grid_conf)->set("parameters",$this->grid_parameters)->render();
			return $view->render();
		}
		
	}
?>